package m.fun.action;

import m.base.action.BaseAction;
import m.common.action.ActionMeta;
import m.common.action.HtmlPageResult;
import m.common.action.HtmlResult;
import m.common.action.RequestMeta;
import m.common.model.util.ModelQueryList;
import m.store.model.SaleInfo;
import m.system.exception.MException;
import m.system.util.JSONMessage;

@ActionMeta(name = "fun/saleOrder")
public class SaleOrderAction extends BaseAction {
    @RequestMeta(params = {"oid"})
    public HtmlResult viewH5(String oid) throws Exception {
        SaleInfo sale= ModelQueryList.getModel(SaleInfo.class,oid,"*","store.name","inputUser.realname","guest.name","guest.tel");
        if(null==sale) throw new MException(this.getClass(),"订单错误");
        JSONMessage verify=new JSONMessage();
        verify.push("name",sale.getGuest().getName().charAt(0)+"****");
        verify.push("tel",sale.getGuest().getTel().substring(0,3)+"****");
        verify.push("verify",false);
        SaleInfo model=new SaleInfo();
        model.setOid(sale.getOid());
        model.setOrderNo(sale.getOrderNo());
        model.setInputUser(sale.getInputUser());
        model.setStore(sale.getStore());
        return new HtmlPageResult("page/fun/saleOrder.html")
                .addParam("verify",verify)
                .addParam("model",model);
    }
}
